<?php

namespace Callback;

use C\L\AdmController;
use C\L\Logs;

class KuaiDi100Controller extends AdmController
{

    protected function init()
    {
        $this->logger = (new Logs)->set('shipment_subscibe_' . date('Ymd') . '.log');
    }

    public function indexAction()
    {
        try {
            $param = $this->request->getPost('param');

            $this->logger->notice('快递100 回调参数：' . $param);

            $data = json_decode($param, true);
            if (!$data) {
                throw new \Exception('返回信息有误');
            }

            $this->s_shipment->updateByKuaidi100($data);

            echo json_encode([
                'result'     => true,
                'returnCode' => '200',
                'message'    => '成功',
            ]);
        } catch (\Exception $e) {
            echo json_encode([
                'result'     => true,
                'returnCode' => '500',
                'message'    => $e->getMessage(),
            ]);
        }
    }
}
